package Handler;

import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JList;

public class ListTransferHandler extends StringTransferHandler {

    private int[] indices;
    private int addIndex;
    private int addCount;

    public ListTransferHandler() {
        indices = null;
        addIndex = -1;
        addCount = 0;
    }

    @Override
    protected String exportString(JComponent c) {
        JList list = (JList) c;
        indices = list.getSelectedIndices();
        Object[] values = list.getSelectedValues();
        StringBuffer buff = new StringBuffer();
        for (int i = 0; i < values.length; i++) {
            Object val =  values[i];
            buff.append(val == null ? "" : val.toString());
            if (i != values.length - 1) {
                buff.append("\n");
            }
        }
        return buff.toString();
    }

    @Override
    protected void importString(JComponent c, String str) {
        //NO IMPLEMENTADO
    }

    @Override
    protected void cleanup(JComponent c, boolean remove) {
        //NO IMPLEMENTADO
    }
}
